push tag:

  1. git push \<remote> tag_name # push a single tag
  2. git push \<origin> --tags # push all tags

undo all uncommit changes:

  1. git clean -fd # delete all untracked files and directories
  2. git reset --hard # removes staged and working directory changes
  3. git checkout /path/to/your/file # checkout a file from HEAD, and overwrite your change.

pring branch tree

.gitconfig 中添加:

1
2
[alias]
lg = log --graph --abbrev-commit --decorate --format=format:'%C(cyan)%h%C(reset) - %C(white)%s%C(reset) %C(yellow)%d%C(reset) %C(dim white) - %anC(reset) %C(dim green)(%ci)%C(reset)' --all

使用命令git lg就可以在命令行中看到branch tree 了

Reference

回滚到指定 commit id

1
2
3
4
5

git reset --hard 0682c06
HEAD is now at 0682c06
$ git reset --soft HEAD@{1}
$ git commit -m "Reverting to the state of the project at 0682c06"

Reference

save HTTPS account

  1. (Recommended) attach credential to remote repository url: https://username:password@git.coding.net/username/repository.git
  2. store temporarily: execute command git config credential.helper 'cache --timeout=60', then credential will expire after 60 seconds since last use.
  3. store permanently: execute command git config --global credential.helper store, then credential will be stored in file ~/.git-credentials and ~/.gitconfig permanently.

Reference: